
 <!DOCTYPE HTML>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  
    <title>Angular2使用笔记5--动画和制作index页面 | Here. There.</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=3, minimum-scale=1">
    
    <meta name="author" content="被删">
    
    <meta name="description" content="最近在学习Angular2作为前端的框架，《Angular2使用笔记》系列用于记录过程中的一些使用和解决方法。本文简单介绍angular2的动画效果，以及记录制作首页的过程。">
    
    
    
    
    <link rel="alternate" href="/atom.xml" title="Here. There." type="application/atom+xml">
    
    
    <link rel="icon" href="/img/favicon.ico">
    
    
    <link rel="apple-touch-icon" href="/img/pacman.jpg">
    <link rel="apple-touch-icon-precomposed" href="/img/pacman.jpg">
    
    <link rel="stylesheet" href="/css/style.css">
    
<script type="text/javascript">
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "//hm.baidu.com/hm.js?3d902de4a19cf2bf179534ffd2dd7b7f";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>

</head>

  <body>
    <header>
      <div>
		
			<div id="imglogo">
				<a href="/"><img src="/img/sun.png" alt="Here. There." title="Here. There."/></a>
			</div>
			
			<div id="textlogo">
				<h1 class="site-name"><a href="/" title="Here. There.">Here. There.</a></h1>
				<h2 class="blog-motto">Love ice cream. Love sunshine. Love life. Love the world. Love myself. Love you.</h2>
			</div>
			<div class="navbar"><a class="navbutton navmobile" href="#" title="菜单">
			</a></div>
			<nav class="animated">
				<ul>
					
						<li><a href="/">首页</a></li>
					
						<li><a href="https://github.com/godbasin/godbasin.github.io">所有文章</a></li>
					
						<li><a href="/archives">归档</a></li>
					
						<li><a href="/categories">分类</a></li>
					
						<li><a href="https://godbasin.github.io/front-end-playground">前端游乐场</a></li>
					
						<li><a href="/about">关于我</a></li>
					
				</ul>
			</nav>			
</div>

    </header>
    <div id="container">
      <div id="main" class="post" itemscope itemprop="blogPost">
	<article itemprop="articleBody"> 
		<header class="article-info clearfix">
  <h1 itemprop="name">
    
      <a href="/2016/10/29/angular2-notes-5-animation-and-create-index/" title="Angular2使用笔记5--动画和制作index页面" itemprop="url">Angular2使用笔记5--动画和制作index页面</a>
  </h1>
  <p class="article-author">By
    
      <a href="https://godbasin.github.io" title="被删">被删</a>
    </p>
  <p class="article-time">
    <time datetime="2016-10-29T01:51:17.000Z" itemprop="datePublished">2016-10-29</time>
    更新日期:<time datetime="2018-12-18T15:30:23.868Z" itemprop="dateModified">2018-12-18</time>
    
  </p>
</header>
	<div class="article-content">
		
		
		<div id="toc" class="toc-article">
			<strong class="toc-title">文章目录</strong>
		<ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#angular2动画"><span class="toc-number">1.</span> <span class="toc-text">angular2动画</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#关于Angular2动画"><span class="toc-number">1.1.</span> <span class="toc-text">关于Angular2动画</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#状态与转场"><span class="toc-number">1.2.</span> <span class="toc-text">状态与转场</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#可动的-Animatable-属性与单位"><span class="toc-number">1.3.</span> <span class="toc-text">可动的(Animatable)属性与单位</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#制作index页面"><span class="toc-number">2.</span> <span class="toc-text">制作index页面</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#添加index组件相关文件"><span class="toc-number">2.1.</span> <span class="toc-text">添加index组件相关文件</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#定义Index组件"><span class="toc-number">2.2.</span> <span class="toc-text">定义Index组件</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#添加组件模板"><span class="toc-number">2.3.</span> <span class="toc-text">添加组件模板</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#添加Index路由"><span class="toc-number">2.4.</span> <span class="toc-text">添加Index路由</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#添加样式"><span class="toc-number">2.5.</span> <span class="toc-text">添加样式</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#结束语"><span class="toc-number">3.</span> <span class="toc-text">结束语</span></a></li></ol>
		</div>
		
		<p>最近在学习Angular2作为前端的框架，《Angular2使用笔记》系列用于记录过程中的一些使用和解决方法。<br>本文简单介绍angular2的动画效果，以及记录制作首页的过程。<br><a id="more"></a></p>
<h2 id="angular2动画"><a href="#angular2动画" class="headerlink" title="angular2动画"></a>angular2动画</h2><hr>
<h3 id="关于Angular2动画"><a href="#关于Angular2动画" class="headerlink" title="关于Angular2动画"></a>关于Angular2动画</h3><ul>
<li>使用动画使得用户界面能在不同的状态之间更平滑的转场</li>
<li>Angular2的动画系统赋予了制作各种动画效果的能力，以构建出与原生CSS动画性能相同的动画</li>
<li>Angular2动画是基于标准的Web动画API(Web Animations API)构建的，它们在支持此API的浏览器中会用原生方式工作。至于其它浏览器，就需要一个填充库(polyfill)</li>
</ul>
<h3 id="状态与转场"><a href="#状态与转场" class="headerlink" title="状态与转场"></a>状态与转场</h3><p>Angular2动画是由状态和状态之间的转场效果所定义的。</p>
<ul>
<li>状态<ul>
<li>动画状态是一个由程序代码中定义的字符串值</li>
<li>状态的来源可以是简单的对象属性，也可以是由方法计算出来的值。能从组件模板中读取它</li>
<li>state具体定义了每个状态的最终样式<ul>
<li>一旦元素转场到那个状态，样式就会被应用到此元素上</li>
<li>当留在此状态时，样式也会一直保持着</li>
</ul>
</li>
</ul>
</li>
<li>转场<ul>
<li>转场控制一条在一组样式和下一组样式之间切换的时间线</li>
<li>如果多个转场都有同样的时间线配置，就可以把它们合并进同一个transition定义中</li>
<li>对同一个转场的两个方向都使用相同的时间线，可以使用&lt;=&gt;简写语法</li>
<li>*(通配符)状态：匹配任何动画状态，可用于定义那些不需要管当前处于什么状态的样式及转场</li>
<li>void状态：表示元素没有被附加到视图，在定义“进场”和“离场”的动画时非常有用</li>
</ul>
</li>
</ul>
<h3 id="可动的-Animatable-属性与单位"><a href="#可动的-Animatable-属性与单位" class="headerlink" title="可动的(Animatable)属性与单位"></a>可动的(Animatable)属性与单位</h3><ul>
<li><p>可以参与动画的属性</p>
<ul>
<li>位置(position)</li>
<li>大小(size)</li>
<li>变换(transform)</li>
<li>颜色(color)</li>
<li>边框(border)<br>尺寸类属性(如位置、大小、边框等)包括一个数字值和一个用来定义长度单位的后缀。</li>
</ul>
</li>
<li><p>动画时间线</p>
<ul>
<li>持续时间(duration)：控制动画从开始到结束要花多长时间</li>
<li>延迟(delay)：控制在动画已经触发但尚未真正开始转场之前要等待多久</li>
<li>缓动(easing)函数：用于控制动画在运行期间如何加速和减速</li>
</ul>
</li>
<li><p>基于关键帧(Keyframes)的多阶段动画</p>
<ul>
<li>每个关键帧都可以被指定一个偏移量，用来定义该关键帧将被用在动画期间的哪个时间点</li>
<li>偏移量是一个介于0(表示动画起点)和1(表示动画终点)之间的数组</li>
</ul>
</li>
<li><p>并行动画组(Group)</p>
<ul>
<li>为同时发生的几个动画配置不同的时间线</li>
</ul>
</li>
</ul>
<h2 id="制作index页面"><a href="#制作index页面" class="headerlink" title="制作index页面"></a>制作index页面</h2><hr>
<p>页面结构如下：<br><img src="https://github-imglib-1255459943.cos.ap-chengdu.myqcloud.com/F3A2.tmp.png" alt="image"></p>
<h3 id="添加index组件相关文件"><a href="#添加index组件相关文件" class="headerlink" title="添加index组件相关文件"></a>添加index组件相关文件</h3><ul>
<li>添加index文件夹，用于管理Index组件的相关文件<br>Index组件文件如下：<figure class="highlight cmd"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">index/</div><div class="line"> ├──index.ts                   * 导出该目录下组件</div><div class="line"> ├──index.component.ts         * 定义并导出Index组件</div><div class="line"> ├──index.style.css            * Index组件的css样式</div><div class="line"> └──index.template.html        * Index组件的html模板</div></pre></td></tr></table></figure>
</li>
</ul>
<h3 id="定义Index组件"><a href="#定义Index组件" class="headerlink" title="定义Index组件"></a>定义Index组件</h3><p>这里使用了前面章节创建的头部组件。前面我们将该组件放在主页面组件app.component.js中，这里我们将其移动到index页面组件中。<br>在index.component.js中：<br><figure class="highlight typescript"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div><div class="line">56</div><div class="line">57</div><div class="line">58</div><div class="line">59</div><div class="line">60</div><div class="line">61</div><div class="line">62</div><div class="line">63</div><div class="line">64</div><div class="line">65</div><div class="line">66</div><div class="line">67</div><div class="line">68</div><div class="line">69</div><div class="line">70</div><div class="line">71</div><div class="line">72</div><div class="line">73</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">import</span> &#123; Component, trigger, state, style, transition, animate &#125; from <span class="string">'@angular/core'</span>;</div><div class="line"></div><div class="line"><span class="comment">// 添加Header组件，默认从header文件夹的index.ts中获取</span></div><div class="line"><span class="keyword">import</span> &#123; Header &#125; from <span class="string">'../header'</span>;</div><div class="line"></div><div class="line">@Component(&#123;</div><div class="line">  selector: <span class="string">'index'</span>, <span class="comment">// 设置模板元素</span></div><div class="line">  styleUrls: [<span class="string">'./index.style.css'</span>], <span class="comment">// 样式文件引入</span></div><div class="line">  templateUrl: <span class="string">'./index.template.html'</span>, <span class="comment">// 模板文件引入</span></div><div class="line">  directives: [Header], <span class="comment">// 注入指令</span></div><div class="line">  animations: [</div><div class="line">    <span class="comment">// 设置动画，@menuState属性动画效果</span></div><div class="line">    trigger(<span class="string">'menuState'</span>, [ </div><div class="line">      state(<span class="string">'false'</span>, style(&#123; <span class="comment">// menu.show为false时状态</span></div><div class="line">        height: <span class="string">'0px'</span>,</div><div class="line">        padding: <span class="string">'0px'</span>,</div><div class="line">        opacity: <span class="string">'0'</span></div><div class="line">      &#125;)),</div><div class="line">      <span class="comment">// 转场的动画效果</span></div><div class="line">      transition(<span class="string">'* =&gt; *'</span>, animate(<span class="string">'100ms ease-in'</span>))</div><div class="line">    ])</div><div class="line">  ]</div><div class="line">&#125;)</div><div class="line"><span class="keyword">export</span> <span class="keyword">class</span> Index &#123;</div><div class="line">  <span class="comment">// 定义并初始化菜单显示状态</span></div><div class="line">  loading: <span class="built_in">string</span> = <span class="string">'init'</span>;</div><div class="line">  asidemenus: <span class="built_in">Array</span>&lt;<span class="built_in">any</span>&gt;;</div><div class="line"></div><div class="line">  <span class="comment">// 更新loading</span></div><div class="line">  changeState (view) &#123;</div><div class="line">    <span class="keyword">this</span>.loading = view;</div><div class="line">  &#125;</div><div class="line"></div><div class="line">  <span class="comment">// 显示隐藏子菜单效果并更新loading</span></div><div class="line">  toggleContent (index) &#123;</div><div class="line">    <span class="keyword">this</span>.asidemenus[index].show = !<span class="keyword">this</span>.asidemenus[index].show;</div><div class="line">    <span class="keyword">this</span>.changeState(<span class="keyword">this</span>.asidemenus[index].click);</div><div class="line">  &#125;</div><div class="line"></div><div class="line">  ngOnInit () &#123;</div><div class="line">    <span class="comment">// 设定menu的初始值</span></div><div class="line">    <span class="keyword">this</span>.asidemenus = [&#123;</div><div class="line">        title: <span class="string">'基本资料'</span>, <span class="comment">// title用于储存该菜单显示名称</span></div><div class="line">        click: <span class="string">'init'</span>, <span class="comment">// click用于储存该菜单对应点击时loading的状态值</span></div><div class="line">        show: <span class="literal">true</span>, <span class="comment">// show用于保存菜单是否隐藏的状态</span></div><div class="line">        menus: [&#123;</div><div class="line">          text: <span class="string">'名字'</span>, <span class="comment">// title用于储存该菜单显示名称</span></div><div class="line">          state: <span class="string">'active'</span>, <span class="comment">// state用于储存该菜单状态</span></div><div class="line">          click: <span class="string">'name'</span> <span class="comment">// click用于储存该菜单对应点击时loading的状态值</span></div><div class="line">        &#125;, &#123;</div><div class="line">          text: <span class="string">'邮箱'</span>,</div><div class="line">          state: <span class="string">'active'</span>,</div><div class="line">          click: <span class="string">'email'</span></div><div class="line">        &#125;, &#123;</div><div class="line">          text: <span class="string">'github'</span>,</div><div class="line">          state: <span class="string">'active'</span>,</div><div class="line">          click: <span class="string">'github'</span></div><div class="line">        &#125;]</div><div class="line">      &#125;, &#123;</div><div class="line">        title: <span class="string">'设置头像'</span>,</div><div class="line">        click: <span class="string">'sethead'</span>,</div><div class="line">        show: <span class="literal">true</span></div><div class="line">      &#125;, &#123;</div><div class="line">        title: <span class="string">'修改资料'</span>,</div><div class="line">        click: <span class="string">'setinfo'</span>,</div><div class="line">        show: <span class="literal">true</span></div><div class="line">      &#125;, &#123;</div><div class="line">        title: <span class="string">'其他'</span>,</div><div class="line">        click: <span class="string">'other'</span>,</div><div class="line">        show: <span class="literal">true</span></div><div class="line">      &#125;];</div><div class="line">  &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<ul>
<li>添加组件样式index.style.css，这里就不展示出来了</li>
<li>index文件夹下index.ts中输出组件<figure class="highlight typescript"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">export</span> * from <span class="string">'./index.component'</span>;</div></pre></td></tr></table></figure>
</li>
</ul>
<h3 id="添加组件模板"><a href="#添加组件模板" class="headerlink" title="添加组件模板"></a>添加组件模板</h3><p>index.template.html文件，如下<br><figure class="highlight html"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div></pre></td><td class="code"><pre><div class="line"><span class="comment">&lt;!--插入头部组件，注入指令后生效--&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">my-header</span>&gt;</span><span class="tag">&lt;/<span class="name">my-header</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"container-fluid row"</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">aside</span> <span class="attr">class</span>=<span class="string">"col-md-2  col-md-offset-1"</span> <span class="attr">id</span>=<span class="string">"according"</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"panel-group"</span> <span class="attr">class</span>=<span class="string">"according"</span> <span class="attr">role</span>=<span class="string">"tablist"</span> <span class="attr">aria-multiselectable</span>=<span class="string">"true"</span>&gt;</span></div><div class="line">            <span class="comment">&lt;!--</span></div><div class="line">                *ng-for 中的*是Angular2中template语法的缩写，如果是全部的话，应该为</div><div class="line">                &lt;div ng-for #menu="$implicit" [ng-for-of]="asidemenus" #i="index"&gt;&lt;/div&gt;</div><div class="line">            --&gt;</div><div class="line">            <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"panel panel-default list-group"</span> *<span class="attr">ngFor</span>=<span class="string">"#menu of asidemenus; #i = index"</span>&gt;</span></div><div class="line">                <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"panel-heading"</span> <span class="attr">role</span>=<span class="string">"tab"</span>&gt;</span></div><div class="line">                    <span class="tag">&lt;<span class="name">ul</span> <span class="attr">class</span>=<span class="string">"panel-title "</span>&gt;</span></div><div class="line">                        <span class="tag">&lt;<span class="name">li</span> <span class="attr">data-toggle</span>=<span class="string">"collapse"</span> (<span class="attr">click</span>)=<span class="string">"toggleContent(i)"</span>&gt;</span></div><div class="line">                            &#123;&#123; menu.title &#125;&#125;</div><div class="line">                        <span class="tag">&lt;/<span class="name">li</span>&gt;</span></div><div class="line">                    <span class="tag">&lt;/<span class="name">ul</span>&gt;</span></div><div class="line">                <span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line">                <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"panel-collapse"</span>&gt;</span></div><div class="line">                    <span class="tag">&lt;<span class="name">ul</span> <span class="attr">class</span>=<span class="string">"list-group"</span>&gt;</span></div><div class="line">                        <span class="comment">&lt;!--@menuState属性动画效果--&gt;</span></div><div class="line">                        <span class="tag">&lt;<span class="name">li</span> *<span class="attr">ngFor</span>=<span class="string">"#item of menu.menus; #j = index;"</span> @<span class="attr">menuState</span>=<span class="string">"menu.show"</span> <span class="attr">class</span>=<span class="string">"list-group-item"</span> <span class="attr">role</span>=<span class="string">"button"</span> (<span class="attr">click</span>)=<span class="string">"changeState(item.click)"</span>&gt;</span>&#123;&#123; item.text &#125;&#125;<span class="tag">&lt;/<span class="name">li</span>&gt;</span></div><div class="line">                    <span class="tag">&lt;/<span class="name">ul</span>&gt;</span></div><div class="line">                <span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line">            <span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line">        <span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line">    <span class="tag">&lt;/<span class="name">aside</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">article</span> <span class="attr">class</span>=<span class="string">"col-md-7"</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">section</span> <span class="attr">class</span>=<span class="string">"index-content"</span>&gt;</span></div><div class="line">            <span class="tag">&lt;<span class="name">p</span> [<span class="attr">hidden</span>]=<span class="string">"!(loading === 'init' || loading === 'name')"</span>&gt;</span>昵称：被删<span class="tag">&lt;/<span class="name">p</span>&gt;</span></div><div class="line">            <span class="tag">&lt;<span class="name">p</span> [<span class="attr">hidden</span>]=<span class="string">"!(loading === 'init' || loading === 'email')"</span>&gt;</span>邮箱：wangbeishan@163.com<span class="tag">&lt;/<span class="name">p</span>&gt;</span></div><div class="line">            <span class="tag">&lt;<span class="name">p</span> [<span class="attr">hidden</span>]=<span class="string">"!(loading === 'init' || loading === 'github')"</span>&gt;</span>github: <span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">"https://github.com/godbasin"</span>&gt;</span>github.com/godbasin<span class="tag">&lt;/<span class="name">a</span>&gt;</span><span class="tag">&lt;/<span class="name">p</span>&gt;</span></div><div class="line">            <span class="tag">&lt;<span class="name">div</span> [<span class="attr">hidden</span>]=<span class="string">"!(loading === 'sethead')"</span>&gt;</span>这里是设置头像页面<span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line">            <span class="tag">&lt;<span class="name">div</span> [<span class="attr">hidden</span>]=<span class="string">"!(loading === 'setinfo')"</span>&gt;</span>这里是修改资料页面<span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line">            <span class="tag">&lt;<span class="name">div</span> [<span class="attr">hidden</span>]=<span class="string">"!(loading === 'other')"</span>&gt;</span>这里是其他页面<span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line">        <span class="tag">&lt;/<span class="name">section</span>&gt;</span></div><div class="line">    <span class="tag">&lt;/<span class="name">article</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">div</span>&gt;</span></div></pre></td></tr></table></figure></p>
<h3 id="添加Index路由"><a href="#添加Index路由" class="headerlink" title="添加Index路由"></a>添加Index路由</h3><p>我们在app.routes.ts中添加index页面的路由。</p>
<ul>
<li><p>引入Index组件<br>这里因为该文件夹下也有一个index.ts的文件，所以直接使用”./index”路径的话会有问题，所以我们写到具体的路径。</p>
<figure class="highlight typescript"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line"><span class="comment">// 当然最好大家不要使用这种易冲突的名字</span></div><div class="line"><span class="keyword">import</span> &#123; Index &#125; from <span class="string">'./index/index'</span>;</div></pre></td></tr></table></figure>
</li>
<li><p>添加路由</p>
<figure class="highlight typescript"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">export</span> <span class="keyword">const</span> routes: RouterConfig = [</div><div class="line">  &#123; path: <span class="string">'login'</span>,  component: Login &#125;,</div><div class="line">  &#123; path: <span class="string">'index'</span>,  component: Index &#125;,</div><div class="line">  &#123; path: <span class="string">'**'</span>,    component: Login &#125;</div><div class="line">];</div></pre></td></tr></table></figure>
</li>
</ul>
<h3 id="添加样式"><a href="#添加样式" class="headerlink" title="添加样式"></a>添加样式</h3><p>样式包括一些组件的样式，还有过渡css样式，这里就不列出来了。</p>
<h2 id="结束语"><a href="#结束语" class="headerlink" title="结束语"></a>结束语</h2><hr>
<p>不得不说，angular2中的动画效果跟Vue过渡也是很相像的呢。这些贴心的设定，很多时候都能帮我们减轻不少的负担呢。<br><a href="https://github.com/godbasin/godbasin.github.io/tree/blog-codes/angular2-notes/5-animation-and-create-index" target="_blank" rel="external">此处查看项目代码（仅包含src部分）</a><br><a href="http://angular2-notes.godbasin.com/5-animation-and-create-index/index.html#/index" target="_blank" rel="external">此处查看页面效果</a></p>
  
		
		<p style="margin-top:50px;">
			查看Github有更多内容噢：<a href="https://github.com/godbasin">https://github.com/godbasin</a>
			<br>
			更欢迎来<a href="https://godbasin.github.io/front-end-playground">被删的前端游乐场</a>边撸猫边学前端噢
		</p>
	</div>
	<img src="https://github-imglib-1255459943.cos.ap-chengdu.myqcloud.com/2code2.jpg" width="200" height="200" style="display:block;margin: 0 auto;" />
	<p style="text-align: center;margin-top: 10px;margin-bottom: 20px;">码生艰难，写文不易，给我家猪囤点猫粮了喵~</p>
	<div class="author-right">
  		<p>作者：被删</p>
  		<p>出处：<a href="https://godbasin.github.io">https://godbasin.github.io</a></p>
  		<p>本文版权归作者所有，欢迎转载，但未经作者同意必须保留此段声明，且在文章页面明显位置给出原文连接，否则保留追究法律责任的权利。</p>
	</div>
		<footer class="article-footer clearfix">

  <div class="article-tags">
  
  <span></span> <a href="/tags/笔记/">笔记</a>
  </div>


<div class="article-categories">
  <span></span>
  <a class="article-category-link" href="/categories/angular2火锅/">angular2火锅</a>
</div>



<div class="article-share" id="share">

  
<!-- JiaThis Button BEGIN -->
<div class="jiathis_style_24x24">
	<a class="jiathis_button_qzone"></a>
	<a class="jiathis_button_tsina"></a>
	<a class="jiathis_button_tqq"></a>
	<a class="jiathis_button_weixin"></a>
	<a class="jiathis_button_renren"></a>
	<a href="http://www.jiathis.com/share?uid=2134021" class="jiathis jiathis_txt jtico jtico_jiathis" target="_blank"></a>
</div>
<script type="text/javascript">
var jiathis_config = {data_track_clickback:'true'};
</script>
<script type="text/javascript" src="http://v3.jiathis.com/code_mini/jia.js?uid=2134021" charset="utf-8"></script>
<!-- JiaThis Button END -->   


</div>
</footer>   	       
	</article>
	
<nav class="article-nav clearfix">
 
 <div class="prev" >
 <a href="/2016/10/30/angular2-notes-6-use-service-class/" title="Angular2使用笔记6--使用服务类">
  <strong>PREVIOUS:</strong><br/>
  <span>
  Angular2使用笔记6--使用服务类</span>
</a>
</div>


<div class="next">
<a href="/2016/10/16/angular2-notes-4-route-component/"  title="Angular2使用笔记4--路由和导航">
 <strong>NEXT:</strong><br/> 
 <span>Angular2使用笔记4--路由和导航
</span>
</a>
</div>

</nav>

	<!-- 如果不是首页且没使用 `comments: false` 关闭评论，则尝试加载评论 -->

    <!-- 配置中启用多说时，导入相应代码 -->
    


</div>  
      <div class="openaside"><a class="navbutton" href="#" title="显示侧边栏"></a></div>

  <div id="toc" class="toc-aside">
  <strong class="toc-title">文章目录</strong>
  <ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#angular2动画"><span class="toc-number">1.</span> <span class="toc-text">angular2动画</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#关于Angular2动画"><span class="toc-number">1.1.</span> <span class="toc-text">关于Angular2动画</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#状态与转场"><span class="toc-number">1.2.</span> <span class="toc-text">状态与转场</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#可动的-Animatable-属性与单位"><span class="toc-number">1.3.</span> <span class="toc-text">可动的(Animatable)属性与单位</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#制作index页面"><span class="toc-number">2.</span> <span class="toc-text">制作index页面</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#添加index组件相关文件"><span class="toc-number">2.1.</span> <span class="toc-text">添加index组件相关文件</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#定义Index组件"><span class="toc-number">2.2.</span> <span class="toc-text">定义Index组件</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#添加组件模板"><span class="toc-number">2.3.</span> <span class="toc-text">添加组件模板</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#添加Index路由"><span class="toc-number">2.4.</span> <span class="toc-text">添加Index路由</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#添加样式"><span class="toc-number">2.5.</span> <span class="toc-text">添加样式</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#结束语"><span class="toc-number">3.</span> <span class="toc-text">结束语</span></a></li></ol>
  </div>

<div id="asidepart">
<div class="closeaside"><a class="closebutton" href="#" title="隐藏侧边栏"></a></div>
<aside class="clearfix">

  	
	<div class="archiveslist">
		<p class="asidetitle">最近文章</p>
			<ul class="archive-list">
			
					
				<li class="archive-list-item">
					<a class="archive-list-link" href="/2019/11/15/wxapp-latest-20191115/" title="小程序开发月刊第11期（20191115）">小程序开发月刊第11期（201911...</a>
				</li>
				
			
					
				<li class="archive-list-item">
					<a class="archive-list-link" href="/2019/11/10/change-log/" title="前端 CHANGELOG 生成指南">前端 CHANGELOG 生成指南...</a>
				</li>
				
			
					
				<li class="archive-list-item">
					<a class="archive-list-link" href="/2019/11/09/wxapp-global-data-behavior/" title="小程序的奇技淫巧 -- globalDataBehavior管理全局状态">小程序的奇技淫巧 -- global...</a>
				</li>
				
			
					
				<li class="archive-list-item">
					<a class="archive-list-link" href="/2019/10/15/wxapp-latest-20191015/" title="小程序开发月刊第十期（20191015）">小程序开发月刊第十期（2019101...</a>
				</li>
				
			
					
				<li class="archive-list-item">
					<a class="archive-list-link" href="/2019/10/13/about-front-end-3-growth/" title="前端这几年--3.关于成长和焦虑">前端这几年--3.关于成长和焦虑...</a>
				</li>
				
			
					
				<li class="archive-list-item">
					<a class="archive-list-link" href="/2019/09/16/wxapp-latest-20190916/" title="小程序开发月刊第九期（20190916）">小程序开发月刊第九期（2019091...</a>
				</li>
				
			
					
				<li class="archive-list-item">
					<a class="archive-list-link" href="/2019/08/15/wxapp-latest-20190815/" title="小程序开发月刊第八期（20190815）">小程序开发月刊第八期（2019081...</a>
				</li>
				
			
					
				<li class="archive-list-item">
					<a class="archive-list-link" href="/2019/07/27/front-end-playground/" title="被删的前端游乐场建成！">被删的前端游乐场建成！</a>
				</li>
				
			
					
				<li class="archive-list-item">
					<a class="archive-list-link" href="/2019/07/21/vue-for-everyone-3/" title="9102全员学Vue--3.把页面拼成个Web应用">9102全员学Vue--3.把页面拼...</a>
				</li>
				
			
					
				<li class="archive-list-item">
					<a class="archive-list-link" href="/2019/07/15/wxapp-latest-20190715/" title="小程序开发月刊第七期（20190715）">小程序开发月刊第七期（2019071...</a>
				</li>
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
			</ul>
	</div>


  
  <div class="archiveslist">
    <p class="asidetitle"><a href="/archives">归档</a></p>
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/11/">十一月 2019</a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/10/">十月 2019</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/09/">九月 2019</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/08/">八月 2019</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/07/">七月 2019</a><span class="archive-list-count">4</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/06/">六月 2019</a><span class="archive-list-count">4</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/05/">五月 2019</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/04/">四月 2019</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/03/">三月 2019</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/02/">二月 2019</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/01/">一月 2019</a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/12/">十二月 2018</a><span class="archive-list-count">4</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/11/">十一月 2018</a><span class="archive-list-count">4</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/10/">十月 2018</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/09/">九月 2018</a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/08/">八月 2018</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/07/">七月 2018</a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/06/">六月 2018</a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/05/">五月 2018</a><span class="archive-list-count">5</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/04/">四月 2018</a><span class="archive-list-count">4</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/03/">三月 2018</a><span class="archive-list-count">7</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/02/">二月 2018</a><span class="archive-list-count">4</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/01/">一月 2018</a><span class="archive-list-count">9</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/12/">十二月 2017</a><span class="archive-list-count">5</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/11/">十一月 2017</a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/10/">十月 2017</a><span class="archive-list-count">5</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/09/">九月 2017</a><span class="archive-list-count">6</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/08/">八月 2017</a><span class="archive-list-count">11</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/07/">七月 2017</a><span class="archive-list-count">9</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/06/">六月 2017</a><span class="archive-list-count">10</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/05/">五月 2017</a><span class="archive-list-count">15</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/04/">四月 2017</a><span class="archive-list-count">7</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/03/">三月 2017</a><span class="archive-list-count">10</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/02/">二月 2017</a><span class="archive-list-count">41</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/01/">一月 2017</a><span class="archive-list-count">6</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/12/">十二月 2016</a><span class="archive-list-count">7</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/11/">十一月 2016</a><span class="archive-list-count">9</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/10/">十月 2016</a><span class="archive-list-count">5</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/09/">九月 2016</a><span class="archive-list-count">7</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/08/">八月 2016</a><span class="archive-list-count">9</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/07/">七月 2016</a><span class="archive-list-count">14</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/06/">六月 2016</a><span class="archive-list-count">9</span></li></ul>
  </div>


  
<div class="archiveslist">
	<p class="asidetitle"><a href="/categories">分类</a></p>
		<ul class="archive-list">
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/CSS炒饭/" title="CSS炒饭">CSS炒饭<sup>3</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/D3小馒头/" title="D3小馒头">D3小馒头<sup>8</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/angular2火锅/" title="angular2火锅">angular2火锅<sup>25</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/angular混搭/" title="angular混搭">angular混搭<sup>33</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/box2djs方糖/" title="box2djs方糖">box2djs方糖<sup>34</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/cyclejs哈根达斯/" title="cyclejs哈根达斯">cyclejs哈根达斯<sup>8</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/jQuery杂烩/" title="jQuery杂烩">jQuery杂烩<sup>3</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/js什锦/" title="js什锦">js什锦<sup>26</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/react沙拉/" title="react沙拉">react沙拉<sup>16</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/three-js奶茶/" title="three.js奶茶">three.js奶茶<sup>5</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/vue八宝粥/" title="vue八宝粥">vue八宝粥<sup>29</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/webpack宾治/" title="webpack宾治">webpack宾治<sup>9</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/web乱炖/" title="web乱炖">web乱炖<sup>2</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/前端满汉全席/" title="前端满汉全席">前端满汉全席<sup>8</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/喵/" title="喵">喵<sup>2</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/小程序双皮奶/" title="小程序双皮奶">小程序双皮奶<sup>27</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/工作这杯茶/" title="工作这杯茶">工作这杯茶<sup>5</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/应用巧克力盒/" title="应用巧克力盒">应用巧克力盒<sup>2</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/思想棉花糖/" title="思想棉花糖">思想棉花糖<sup>8</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/柴米油盐工具集/" title="柴米油盐工具集">柴米油盐工具集<sup>1</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/自动化甜筒/" title="自动化甜筒">自动化甜筒<sup>1</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/非前端钙片/" title="非前端钙片">非前端钙片<sup>7</sup></a>
			</li>
		
		</ul>
</div>


  
<div class="archiveslist">
	<p class="asidetitle">标签</p>
		<ul class="archive-list">
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/tags/分享/" title="分享">分享<sup>44</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/tags/原创部件/" title="原创部件">原创部件<sup>1</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/tags/心态/" title="心态">心态<sup>5</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/tags/教程/" title="教程">教程<sup>73</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/tags/晒猫/" title="晒猫">晒猫<sup>2</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/tags/笔记/" title="笔记">笔记<sup>121</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/tags/算法/" title="算法">算法<sup>9</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/tags/自制插件/" title="自制插件">自制插件<sup>2</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/tags/逻辑实现/" title="逻辑实现">逻辑实现<sup>5</sup></a>
			</li>
		
		</ul>
</div>


    <div class="archiveslist">
    <p class="asidetitle"><a href="/archives">about</a></p>
      <ul class="archive-list">
      	<li class="archive-list-item">
      		<a>wangbeishan@163.com</a>
      		<a href="https://github.com/godbasin">github.com/godbasin</a>
      	</li>
      </ul>
  </div>

  <div class="rsspart">
	<a href="/atom.xml" target="_blank" title="rss">RSS 订阅</a>
</div>

</aside>
</div>
    </div>
    <footer><div id="footer" >
	
	<section class="info">
		<p> 即使梦想再小，却很伟大 ^_^ </p>
	</section>
	 
		<p class="copyright">Powered by <a href="http://hexo.io" target="_blank" title="hexo">hexo</a> and Theme by <a href="https://github.com/A-limon/pacman" target="_blank" title="Pacman">Pacman</a> © 2019 
		
		<a href="https://godbasin.github.io" target="_blank" title="被删">被删</a>
		
		</p>
</div>
</footer>
    <script src="/js/jquery-2.1.0.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){ 
  $('.navbar').click(function(){
    $('header nav').toggleClass('shownav');
  });
  var myWidth = 0;
  function getSize(){
    if( typeof( window.innerWidth ) == 'number' ) {
      myWidth = window.innerWidth;
    } else if( document.documentElement && document.documentElement.clientWidth) {
      myWidth = document.documentElement.clientWidth;
    };
  };
  var m = $('#main'),
      a = $('#asidepart'),
      c = $('.closeaside'),
      o = $('.openaside');
  $(window).resize(function(){
    getSize(); 
    if (myWidth >= 1024) {
      $('header nav').removeClass('shownav');
    }else
    {
      m.removeClass('moveMain');
      a.css('display', 'block').removeClass('fadeOut');
      o.css('display', 'none');
      
      $('#toc.toc-aside').css('display', 'none');
        
    }
  });
  c.click(function(){
    a.addClass('fadeOut').css('display', 'none');
    o.css('display', 'block').addClass('fadeIn');
    m.addClass('moveMain');
  });
  o.click(function(){
    o.css('display', 'none').removeClass('beforeFadeIn');
    a.css('display', 'block').removeClass('fadeOut').addClass('fadeIn');      
    m.removeClass('moveMain');
  });
  $(window).scroll(function(){
    o.css("top",Math.max(80,260-$(this).scrollTop()));
  });
});
</script>

<script type="text/javascript">
$(document).ready(function(){ 
  var ai = $('.article-content>iframe'),
      ae = $('.article-content>embed'),
      t  = $('#toc'),
      h  = $('article h2')
      ah = $('article h2'),
      ta = $('#toc.toc-aside'),
      o  = $('.openaside'),
      c  = $('.closeaside');
  if(ai.length>0){
    ai.wrap('<div class="video-container" />');
  };
  if(ae.length>0){
   ae.wrap('<div class="video-container" />');
  };
  if(ah.length==0){
    t.css('display','none');
  }else{
    c.click(function(){
      ta.css('display', 'block').addClass('fadeIn');
    });
    o.click(function(){
      ta.css('display', 'none');
    });
    $(window).scroll(function(){
      ta.css("top",Math.max(140,320-$(this).scrollTop()));
    });
  };
});
</script>







  </body>
</html>
